package reduce.fz.com.reduce.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.adapter.BaseListAdapter;
import reduce.fz.com.reduce.adapter.BaseRecycleViewHolder;
import reduce.fz.com.reduce.bean.Card;
import reduce.fz.com.reduce.bean.result.UserWitness;
import reduce.fz.com.reduce.fragment.base.BaseListFragment;

/**
 * Created by qingshengzheng on 15/9/9.
 */
public class TeamCardDynamicFragment extends BaseListFragment<TeamCardDynamicFragment.MyViewHolder, Card> {
    private String requesturl;
    private Long teamid;

    public static TeamCardDynamicFragment create(Long teamid) {
        Bundle bundle = new Bundle();
        if (teamid != null)
            bundle.putLong("teamid", teamid);
        TeamCardDynamicFragment fragment = new TeamCardDynamicFragment();
        fragment.setArguments(bundle);
        return fragment;

    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);
        teamid = getArguments().getLong("teamid");
        return view;
    }

    public TeamCardDynamicFragment() {
    }

    @Override
    public MyViewHolder createItemViewHolder(ViewGroup parent) {
        View view = layoutInflater.inflate(R.layout.witness_card_dynamic_item, null);
        return new MyViewHolder(view);
    }

    @Override
    public MyViewHolder createfootViewHolder(View view) {
        return new MyViewHolder(view);
    }


    @Override
    public String createReqUrl() {
        return requesturl;
    }

    public  static class MyViewHolder extends BaseRecycleViewHolder<UserWitness> {
        private ImageView user_header;
        private ImageView card_main;
        private ImageView card_1;
        private ImageView card_2;
        private ImageView card_3;
        private ImageView card_4;


        public MyViewHolder(View itemView) {
            super(itemView);
            user_header = (ImageView) itemView.findViewById(R.id.user_header);
            card_main = (ImageView) itemView.findViewById(R.id.card_main);
//            card_1 =(ImageView)itemView.findViewById(R.id.card_1);
//            card_2 =(ImageView)itemView.findViewById(R.id.card_2);
//            card_3 =(ImageView)itemView.findViewById(R.id.card_3);
            // card_4 =(ImageView)itemView.findViewById(R.id.card_4);
        }

        @Override
        public void renderView(UserWitness data,int position) {
            Picasso.with(context).load(R.drawable.shuaige).into(user_header);
            Picasso.with(context).load(R.drawable.paobu).into(card_main);
//            Picasso.with(context).load(R.drawable.shuaige).into(card_1);
//            Picasso.with(context).load(R.drawable.shuaige).into(card_2);
//            Picasso.with(context).load(R.drawable.shuaige).into(card_3);
            //Picasso.with(context).load(R.drawable.shuaige).into(card_4);
        }
    }

    public void request(String url) {
        List<Card> list = new ArrayList<Card>();
        for (int i = 0; i < 6; i++) {
            list.add(new Card());
        }
        baseListAdapter.addDatas(list);


    }


}
